package com.feicheng.lanniao.controller;

import java.beans.Transient;

import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.feicheng.lanniao.entity.Person;
import com.feicheng.lanniao.result.ResultInfo;
import com.feicheng.lanniao.service.IPersonService;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author feichengTech
 * @since 2021-09-02
 */
@RestController
@RequestMapping("/lanniao-admin/person")
public class PersonController {

	/**
	 * 增加客户个人信息
	 * @param person 客户信息对象
	 * @return boolean值
	 */
	@Autowired
	IPersonService IPersonService;
	@PostMapping("/info")
	@Transactional
	public ResultInfo addpersonInfo(Person person) {
		IPersonService.addPersonInfo(person);
		return ResultInfo.success();
	}

	/**
	 * 修改个人信息 
	 * @param person 客户信息对象
	 * @return boolean值
	 */
	@PutMapping("/info")
	@Transient
	public ResultInfo updatePersonInfo(Person person) {
		return IPersonService.updatPersonInfo(person);
	}
	
	/**
	 * 通过修改delete_flag达到假删除效果
	 * @param id 客户账号id
	 * @return boolean值
	 */
	@DeleteMapping("/info")
	public ResultInfo delete(int id) {
		ResultInfo resultInfo = ResultInfo.success();
		return resultInfo;
	}
	
	/**
	 * 根据id查询客户信息
	 * @param personId
	 * @return person对象
	 */
	@GetMapping("/info")
	@Transient
	public ResultInfo selectOneInfo(Integer personId) {
		return IPersonService.selectOneInfo(personId);
	}
}
